/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.trick.admin.binding;

import it.trick.admin.task.AddChannelTask;
import it.trick.admin.task.ChangeContentsIndexTask;
import it.trick.admin.task.DeleteChannelTask;
import it.trick.admin.task.LoadChannelListTask;
import it.trick.admin.task.UpdateChannelTask;
import javafx.beans.binding.BooleanBinding;

/**
 *
 * @author takahara
 */
public class SelectChannelProgressBinding extends BooleanBinding {

    private LoadChannelListTask loadChannelListTask;
    private AddChannelTask addChannelTask;
    private DeleteChannelTask deleteChannelTask;
    private UpdateChannelTask updateChannelTask;
    private ChangeContentsIndexTask changeIndexTask;

    /**
     * コンストラクタ
     */
    public SelectChannelProgressBinding(
            LoadChannelListTask loadChannelListTask,
            AddChannelTask addChannelTask,
            DeleteChannelTask deleteChannelTask,
            UpdateChannelTask updateChannelTask,
            ChangeContentsIndexTask changeIndexTask
            ) {
        this.loadChannelListTask = loadChannelListTask;
        this.addChannelTask = addChannelTask;
        this.deleteChannelTask = deleteChannelTask;
        this.updateChannelTask = updateChannelTask;
        this.changeIndexTask = changeIndexTask;

        super.bind(loadChannelListTask.runningProperty());
        super.bind(addChannelTask.runningProperty());
        super.bind(deleteChannelTask.runningProperty());
        super.bind(updateChannelTask.runningProperty());
        super.bind(changeIndexTask.runningProperty());
    }

    @Override
    protected boolean computeValue() {

        if(loadChannelListTask.runningProperty().getValue()) return true;
        if(addChannelTask.runningProperty().getValue()) return true;
        if(deleteChannelTask.runningProperty().getValue()) return true;
        if(updateChannelTask.runningProperty().getValue()) return true;
        if(changeIndexTask.runningProperty().getValue()) return true;

        return false;
    }
}
